import { request } from 'umi';

/**获取报表头 */
export function GetReportInfo(repReq: API.ReportRequest) {
  const data = JSON.stringify(repReq);
  return request<API.RespData1>(`/api/restricted/report/info`, {
    method: 'POST',
    body: data,
  });
}
/**获取报表数据 */
export function GetReportDataLists(repReq: API.ReportRequest) {
  const data = JSON.stringify(repReq);
  return request<API.RespData2>(`/api/restricted/report/listData`, {
    method: 'POST',
    body: data,
  });
}

/**导出报表数据 */
export function ExportReportDatas(repReq: API.ReportRequest) {
  const data = JSON.stringify(repReq);
  return request(`/api/restricted/report/export`, {
    method: 'POST',
    body: data,
    getResponse: true,
    responseType: 'blob',
  });
}

/*获取所有首页的图形卡片 */
export function getChartCardAll(cyno: string, timeLevel: string) {
  const data = new FormData();
  data.append('cyno', cyno);
  data.append('timeLevel', timeLevel);
  return request<API.ChartCardData[]>(`/api/restricted/report/chartCardAll`, {
    method: 'POST',
    body: data,
  });
}

/*获取首页的图形卡片 */
export function getChartCard(cyno: string, timeLevel: string, title: string) {
  const data = new FormData();
  data.append('cyno', cyno);
  data.append('timeLevel', timeLevel);
  data.append('title', title);
  return request<API.ChartCardData>(`/api/restricted/report/chartCard`, {
    method: 'POST',
    body: data,
  });
}
